package com.phantom.netty.c4;

import io.netty.buffer.ByteBuf;
import io.netty.buffer.ByteBufAllocator;

import static com.phantom.netty.c4.ByteBufTest.log;

public class TestSlice {
    public static void main(String[] args) {

        ByteBuf buf = ByteBufAllocator.DEFAULT.buffer(10);

        buf.writeBytes(new byte[]{'a','b','c','d','e','f','g','h', 'i','j'});
        log(buf);

        ByteBuf f1 = buf.slice(0, 5);
        ByteBuf f2 = buf.slice(5, 5);
        log(f1);
        log(f2);

        System.out.println("\n=========================\n");
        f1.setByte(0, 'b');
        log(f1);
        log(buf);
    }
}
